#pragma once

#include <unordered_map>
#include "Point2D.h"
#include "Coordinates.h"
#include "Color.h"
#include "Plotter.h"

namespace HW2
{

	struct PixelInfo
	{
		bool valid;
		PixelInfo() : valid(false) {}
		PixelInfo(double depth, Color color): depth(depth), color(color), valid(true) {}
		double depth;
		Color color;
		bool operator<(const PixelInfo &other)
		{
			return depth < other.depth;
		}
	};

	struct Z_Buffer : public Plotter
	{
		
		std::vector<std::vector<PixelInfo> > data;
		std::vector<std::vector<std::vector<PixelInfo > > > transparencyData;
		void clear();
		void draw(Plotter &p);
		void drawTransparency(Plotter &p);
		void set(Coordinates p, Color c);

		void plot(int x, int y, double z, Color c, Coordinates orig);


		virtual void fillBackground(Color c);

		Z_Buffer(int width, int height) : data(width, std::vector<PixelInfo>(height)),
			transparencyData(width, std::vector<std::vector<PixelInfo> >(height))
		{
		}
	};

}